Submit Results
curl --request POST \
--url https://api.sophra.org/api/nous/ab-testing/results \
--header 'Content-Type: application/json' \
--data '
{
"testId": "{{testId}}",
"variantId": "control",
"metrics": {
"click_through_rate": 0.15,
"time_on_page": 45.2,
"conversion_rate": 0.08,
"bounce_rate": 0.25
},
"sessionId": "sess_123456",
"metadata": {
"userAgent": "Mozilla/5.0",
"deviceType": "desktop",
"region": "US-West",
"timestamp": "2024-03-20T10:30:00Z"
}
}
'import requests
url = "https://api.sophra.org/api/nous/ab-testing/results"
payload = {
"testId": "{{testId}}",
"variantId": "control",
"metrics": {
"click_through_rate": 0.15,
"time_on_page": 45.2,
"conversion_rate": 0.08,
"bounce_rate": 0.25
},
"sessionId": "sess_123456",
"metadata": {
"userAgent": "Mozilla/5.0",
"deviceType": "desktop",
"region": "US-West",
"timestamp": "2024-03-20T10:30:00Z"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
testId: '{{testId}}',
variantId: 'control',
metrics: {
click_through_rate: 0.15,
time_on_page: 45.2,
conversion_rate: 0.08,
bounce_rate: 0.25
},
sessionId: 'sess_123456',
metadata: {
userAgent: 'Mozilla/5.0',
deviceType: 'desktop',
region: 'US-West',
timestamp: '2024-03-20T10:30:00Z'
}
})
};
fetch('https://api.sophra.org/api/nous/ab-testing/results', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/nous/ab-testing/results",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'testId' => '{{testId}}',
'variantId' => 'control',
'metrics' => [
'click_through_rate' => 0.15,
'time_on_page' => 45.2,
'conversion_rate' => 0.08,
'bounce_rate' => 0.25
],
'sessionId' => 'sess_123456',
'metadata' => [
'userAgent' => 'Mozilla/5.0',
'deviceType' => 'desktop',
'region' => 'US-West',
'timestamp' => '2024-03-20T10:30:00Z'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/nous/ab-testing/results"
payload := strings.NewReader("{\n \"testId\": \"{{testId}}\",\n \"variantId\": \"control\",\n \"metrics\": {\n \"click_through_rate\": 0.15,\n \"time_on_page\": 45.2,\n \"conversion_rate\": 0.08,\n \"bounce_rate\": 0.25\n },\n \"sessionId\": \"sess_123456\",\n \"metadata\": {\n \"userAgent\": \"Mozilla/5.0\",\n \"deviceType\": \"desktop\",\n \"region\": \"US-West\",\n \"timestamp\": \"2024-03-20T10:30:00Z\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/nous/ab-testing/results")
.header("Content-Type", "application/json")
.body("{\n \"testId\": \"{{testId}}\",\n \"variantId\": \"control\",\n \"metrics\": {\n \"click_through_rate\": 0.15,\n \"time_on_page\": 45.2,\n \"conversion_rate\": 0.08,\n \"bounce_rate\": 0.25\n },\n \"sessionId\": \"sess_123456\",\n \"metadata\": {\n \"userAgent\": \"Mozilla/5.0\",\n \"deviceType\": \"desktop\",\n \"region\": \"US-West\",\n \"timestamp\": \"2024-03-20T10:30:00Z\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/nous/ab-testing/results")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"testId\": \"{{testId}}\",\n \"variantId\": \"control\",\n \"metrics\": {\n \"click_through_rate\": 0.15,\n \"time_on_page\": 45.2,\n \"conversion_rate\": 0.08,\n \"bounce_rate\": 0.25\n },\n \"sessionId\": \"sess_123456\",\n \"metadata\": {\n \"userAgent\": \"Mozilla/5.0\",\n \"deviceType\": \"desktop\",\n \"region\": \"US-West\",\n \"timestamp\": \"2024-03-20T10:30:00Z\"\n }\n}"
response = http.request(request)
puts response.read_bodyNous > A/B Testing
Submit Results
POST
/
nous
/
ab-testing
/
results
Submit Results
curl --request POST \
--url https://api.sophra.org/api/nous/ab-testing/results \
--header 'Content-Type: application/json' \
--data '
{
"testId": "{{testId}}",
"variantId": "control",
"metrics": {
"click_through_rate": 0.15,
"time_on_page": 45.2,
"conversion_rate": 0.08,
"bounce_rate": 0.25
},
"sessionId": "sess_123456",
"metadata": {
"userAgent": "Mozilla/5.0",
"deviceType": "desktop",
"region": "US-West",
"timestamp": "2024-03-20T10:30:00Z"
}
}
'import requests
url = "https://api.sophra.org/api/nous/ab-testing/results"
payload = {
"testId": "{{testId}}",
"variantId": "control",
"metrics": {
"click_through_rate": 0.15,
"time_on_page": 45.2,
"conversion_rate": 0.08,
"bounce_rate": 0.25
},
"sessionId": "sess_123456",
"metadata": {
"userAgent": "Mozilla/5.0",
"deviceType": "desktop",
"region": "US-West",
"timestamp": "2024-03-20T10:30:00Z"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
testId: '{{testId}}',
variantId: 'control',
metrics: {
click_through_rate: 0.15,
time_on_page: 45.2,
conversion_rate: 0.08,
bounce_rate: 0.25
},
sessionId: 'sess_123456',
metadata: {
userAgent: 'Mozilla/5.0',
deviceType: 'desktop',
region: 'US-West',
timestamp: '2024-03-20T10:30:00Z'
}
})
};
fetch('https://api.sophra.org/api/nous/ab-testing/results', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/nous/ab-testing/results",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'testId' => '{{testId}}',
'variantId' => 'control',
'metrics' => [
'click_through_rate' => 0.15,
'time_on_page' => 45.2,
'conversion_rate' => 0.08,
'bounce_rate' => 0.25
],
'sessionId' => 'sess_123456',
'metadata' => [
'userAgent' => 'Mozilla/5.0',
'deviceType' => 'desktop',
'region' => 'US-West',
'timestamp' => '2024-03-20T10:30:00Z'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/nous/ab-testing/results"
payload := strings.NewReader("{\n \"testId\": \"{{testId}}\",\n \"variantId\": \"control\",\n \"metrics\": {\n \"click_through_rate\": 0.15,\n \"time_on_page\": 45.2,\n \"conversion_rate\": 0.08,\n \"bounce_rate\": 0.25\n },\n \"sessionId\": \"sess_123456\",\n \"metadata\": {\n \"userAgent\": \"Mozilla/5.0\",\n \"deviceType\": \"desktop\",\n \"region\": \"US-West\",\n \"timestamp\": \"2024-03-20T10:30:00Z\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/nous/ab-testing/results")
.header("Content-Type", "application/json")
.body("{\n \"testId\": \"{{testId}}\",\n \"variantId\": \"control\",\n \"metrics\": {\n \"click_through_rate\": 0.15,\n \"time_on_page\": 45.2,\n \"conversion_rate\": 0.08,\n \"bounce_rate\": 0.25\n },\n \"sessionId\": \"sess_123456\",\n \"metadata\": {\n \"userAgent\": \"Mozilla/5.0\",\n \"deviceType\": \"desktop\",\n \"region\": \"US-West\",\n \"timestamp\": \"2024-03-20T10:30:00Z\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/nous/ab-testing/results")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"testId\": \"{{testId}}\",\n \"variantId\": \"control\",\n \"metrics\": {\n \"click_through_rate\": 0.15,\n \"time_on_page\": 45.2,\n \"conversion_rate\": 0.08,\n \"bounce_rate\": 0.25\n },\n \"sessionId\": \"sess_123456\",\n \"metadata\": {\n \"userAgent\": \"Mozilla/5.0\",\n \"deviceType\": \"desktop\",\n \"region\": \"US-West\",\n \"timestamp\": \"2024-03-20T10:30:00Z\"\n }\n}"
response = http.request(request)
puts response.read_bodyBody
application/json
The body is of type object.
Response
200 - application/json
Successful response

